﻿@using Smartstore.Core.Content.Menus

@model IReadOnlyList<MenuItem>
@inject IBreadcrumb Breadcrumb

@{ 
    var trail = Model ?? Breadcrumb.Trail.AsReadOnly();
    if (trail == null || trail.Count == 0)
    {
        return;
    }
}

<zone name="breadcrumb_before"></zone>

<div class="breadcrumb-container d-none d-md-flex flex-wrap align-items-center mb-4">
    <ol class="breadcrumb mb-0" itemscope itemtype="http://schema.org/BreadcrumbList">
        <li class="breadcrumb-item" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
            <a asp-route="Homepage" title="@T("Categories.Breadcrumb.Top")" itemprop="item">
                <meta itemprop="name" content="@T("HomePage")">
                <meta itemprop="position" content="1">
                <i class="fa fa-home"></i>
            </a>
        </li>
        @for (int i = 0; i < trail.Count - 1; i++)
        {
            var item = trail[i];
            var isLast = i == trail.Count - 1;

            <li class="breadcrumb-item@(isLast ? " active" : "")" itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
                @if (item.HasRoute)
                {
                    <a href="@item.GenerateUrl(this.Url)" title="@item.Text" itemprop="item"><meta itemprop="position" content="@(i + 2)"><span itemprop="name" dir="auto">@item.Text</span></a>
                }
            </li>
        }
    </ol>
    <div class="breadcrumb-item active">
        <span>@trail.LastOrDefault().Text</span>
    </div>
</div>

<zone name="breadcrumb_after"></zone>